package com.yunhe.authority.service.authority;

import com.github.stuxuhai.jpinyin.PinyinException;
import com.yunhe.authority.domain.authority.RealStation;
import com.yunhe.authority.model.RealStationOfficeVo;
import com.yunhe.authority.model.RealStationVo;
import com.yunhe.authority.model.inspect.RealStationOfficeCompanyVo;
import com.yunhe.common.exception.ObjectNotFoundException;
import com.yunhe.common.exception.UniqueConstraintsException;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author zhengbo
 * @date 2021/5/11 16:31
 */
public interface RealStationService {

    RealStation findById(Long id);

    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    RealStation creatRealStation(Long stationId, RealStation realStation) throws PinyinException, UniqueConstraintsException;

    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    RealStation update(RealStation realStation) throws ObjectNotFoundException, UniqueConstraintsException;

    RealStation findByTitle(Long stationId, String title);

    /**
     * 根据总园区id与真实园区title查询真实园区
     * @param stationId 总园区ID
     * @param title 真实园区title
     */
    RealStation findRealStationByStationIdAndTitle(Long stationId, String title);

    /**
     * 根据总园区id与真实园区简称查询真实园区
     * @param stationId 总园区ID
     * @param abbreviationName 真实园区简称
     */
    RealStation findRealStationByStationIdAndAbbreviationName(Long stationId, String abbreviationName);

    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    void deleteById(Long id);

    /**
     * 根据总园区id查询真实园区
     * @param stationId 总园区ID
     */
    Iterable<RealStation> findRealStationByStationId(Long stationId);

    /**
     * 根据总园区id查询真实园区(携带厂房信息)
     * @param stationId 总园区ID
     */
    Iterable<RealStation> searchStationAndOfficeByStationId(Long stationId);

    /**
     * 添加真实园区与厂房关系
     * @param officeId 厂房ID
     * @param id 真实园区ID
     */
    void realStationBindOffice(Long id, Long officeId);


    /**
     * 添加真实园区与企业关系
     * @param companyId 企业ID
     * @param id 真实园区ID
     */
    void realStationBindCompany(Long id, Long companyId);

    /**
     * 根据厂房id查询绑定的真实园区
     * @param officeId 厂房id
     * @return RealStation 0
     */
    RealStation findRealStationByOfficeId(Long officeId);

    /**
     * 根据企业id查询绑定的真实园区
     * @param companyId 企业id
     * @return RealStation 0
     */
    RealStation findRealStationByCompanyId(Long companyId);

    /**
     * 查询当前正式园区的信息
     * @param id
     * @return
     */
    RealStation searchById(Long id);

    @Transactional(rollbackFor = Exception.class, transactionManager = "transactionManager")
    void unbindOfficeByOfficeId(Long id);

    Iterable<RealStation> findAll();

    List<RealStationVo> searchRealStationByStationId(Long valueOf);

    RealStationOfficeVo searchRealStationAndOffice();

    List<RealStationOfficeCompanyVo> searchStationAndOfficeAndCompanyByStationId(Long stationId);

    List<RealStationOfficeCompanyVo> searchStationAndOfficeAndCompany(List<String> value);
}
